package com.hncc.dms.service.impl;

import java.util.List;

import com.hncc.dms.mapper.DmsCaseModelCatalogMapper;
import com.ruoyi.common.core.domain.entity.DmsCaseModelCatalog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hncc.dms.mapper.DmsCaseModelMapper;
import com.hncc.dms.domain.DmsCaseModel;
import com.hncc.dms.service.IDmsCaseModelService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 病历模版Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-08-23
 */
@Service
public class DmsCaseModelServiceImpl implements IDmsCaseModelService 
{
    @Resource
    private DmsCaseModelMapper dmsCaseModelMapper;

    @Resource
    private DmsCaseModelCatalogMapper dmsCaseModelCatalogMapper;

    /**
     * 查询病历模版
     * 
     * @param id 病历模版ID
     * @return 病历模版
     */
    @Override
    public DmsCaseModel selectDmsCaseModelById(Long id)
    {
        return dmsCaseModelMapper.selectDmsCaseModelById(id);
    }

    /**
     * 查询病历模版列表
     * 
     * @param dmsCaseModel 病历模版
     * @return 病历模版
     */
    @Override
    public List<DmsCaseModel> selectDmsCaseModelList(DmsCaseModel dmsCaseModel)
    {
        return dmsCaseModelMapper.selectDmsCaseModelList(dmsCaseModel);
    }

    /**
     * 新增病历模版
     * 
     * @param dmsCaseModel 病历模版
     * @return 结果
     */
    @Override
    public int insertDmsCaseModel(DmsCaseModel dmsCaseModel)
    {
        return dmsCaseModelMapper.insertDmsCaseModel(dmsCaseModel);
    }

    /**
     * 修改病历模版
     * 
     * @param dmsCaseModel 病历模版
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateDmsCaseModel(DmsCaseModel dmsCaseModel)
    {
        DmsCaseModelCatalog dmsCaseModelCatalog = new DmsCaseModelCatalog();
        dmsCaseModelCatalog.setModelId(dmsCaseModel.getId());
        dmsCaseModelCatalog.setName(dmsCaseModel.getName());
        dmsCaseModelCatalogMapper.updateDmsCaseModelCatalog(dmsCaseModelCatalog);
        return dmsCaseModelMapper.updateDmsCaseModel(dmsCaseModel);
    }

    /**
     * 批量删除病历模版
     * 
     * @param ids 需要删除的病历模版ID
     * @return 结果
     */
    @Override
    public int deleteDmsCaseModelByIds(Long[] ids)
    {
        return dmsCaseModelMapper.deleteDmsCaseModelByIds(ids);
    }

    /**
     * 删除病历模版信息
     * 
     * @param id 病历模版ID
     * @return 结果
     */
    @Override
    public int deleteDmsCaseModelById(Long id)
    {
        return dmsCaseModelMapper.deleteDmsCaseModelById(id);
    }
}
